package tests;

import common.Utils;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.io.IOException;
import java.lang.reflect.Method;
import java.time.Duration;

/**
 * @Author xuejiao
 * Data 2025/5/30 10:55
 */
public class ActivityListPage extends Utils {
    public static String url = "http://localhost:8080/activities-list.html";
    public ActivityListPage() {
        super(url);
    }

    public void activityList() throws InterruptedException {
        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(3));
        driver.findElement(By.cssSelector("body > div > h2"));
        Thread.sleep(1000);

    }

    //未登录状态下---访问活动页面
//    public void activityListNoLogin() throws InterruptedException, IOException {
//        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
//
//        // 1. 确保是未登录状态（尝试点击退出按钮）
//        try {
//            WebElement logoutButton = wait.until(ExpectedConditions.presenceOfElementLocated(
//                    By.cssSelector("body > div.header-box > div.user-box > div > span")
//            ));
//            logoutButton.click();
//            System.out.println("已退出登录状态");
//        } catch (Exception e) {
//            System.out.println("当前已是未登录状态");
//        }
//
//        // 2. 跳转活动列表页（此时会立刻弹出 alert）
//        driver.get(url);
//
//
//
//        driver.quit();
//    }

}
